package com.simon.mctm.utils;


/**
 * 通用类
 * @author Jiajie.Mao
 * @date 2018/6/7 15:40
 */
public class Utils {
	
	/***
	 * 计算一共多少页
	 * @param total
	 * @param size
	 * @return
	 */
	static public int calPages(int total,int size ) {
		double aa = (double)total / size;
		return (int)Math.ceil(aa);
	}
	

	/**
	 * 获取指定位数的随机字符串(包含小写字母、大写字母、数字,0<length)
	 * @param length
	 * @return
	 */
	public static String getRandomString(int length) {
	    //随机字符串的随机字符库
	    String KeyString = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
	    StringBuffer sb = new StringBuffer();
	    int len = KeyString.length();
	    for (int i = 0; i < length; i++) {
	       sb.append(KeyString.charAt((int) Math.round(Math.random() * (len - 1))));
	    }
	    return sb.toString();
	}
}
